package app

import (
	"net/http"

	"github.com/gin-gonic/gin"
	"o78k.cn/dapi/core"
	"o78k.cn/dapi/models"
)

func init() {
	POST("/create/user", func(c *gin.Context) {
		var user = models.User{}
		c.ShouldBind(&user)
		db := core.Database.Save(&user)
		if db.Error != nil {
			c.JSON(http.StatusOK, gin.H{
				"message": "create user failed",
			})
			return
		}
		c.JSON(http.StatusOK, gin.H{
			"message": "Hello, world!",
		})
	})

	GET("/audit/user", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"message": "Hello, world!",
		})
	})

}
